<?php

namespace App\Admin\Controllers;

use App\Models\TeamReward;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;

class TeamRewardController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(TeamReward::with(['user', 'child']), function (Grid $grid) {
            $grid->model()->orderByDesc('id');
            $grid->column('id')->sortable();
            $grid->column('deposit_id', '充值/兑换ID');
            $grid->column('p_user_id');
            $grid->column('user.email', '拿奖用户邮箱');
            $grid->column('user.mobile', '拿奖用户手机号');
            $grid->column('c_user_id');
            $grid->column('child.email', '来源用户邮箱');
            $grid->column('child.mobile', '来源用户手机号');;
            $grid->column('number');
            $grid->column('rate');
            $grid->column('get_number');
            $grid->column('type', '来源类型');
            $grid->column('created_at');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->equal('deposit_id', '充值ID');
                $filter->equal('user.email', '拿奖用户邮箱');
                $filter->equal('user.mobile', '拿奖用户手机号');
                $filter->equal('child.email', '来源用户邮箱');
                $filter->equal('child.mobile', '来源用户手机号');
            });
            $grid->disableBatchDelete();
            $grid->disableRowSelector();
            $grid->disableActions();
            $grid->disableCreateButton();
        });
    }
}
